package com.cool.service.sysmanage.impl;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.cool.mapper.sysmanagemapper.ClassifyPoMapper;
import com.cool.po.sysmanagepo.ClassifyPo;
import com.cool.service.sysmanage.ClassifyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 分类服务impl
 *
 * @author Jiangmanman
 * @date 2020/07/29
 */
@Service
public class ClassifyServiceImpl implements ClassifyService {
    @Resource
    private ClassifyPoMapper classifyPoMapper;

    @Override
    public List<ClassifyPo> selectAll() {
        return classifyPoMapper.selectAll();
    }

    @Override
    public Integer deleteById(Integer id) {
        return classifyPoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Integer insert(ClassifyPo classifyPo) {
        DateTime date = DateUtil.date();
        classifyPo.setClassifyCreate(date);
        classifyPo.setClassifyUpdate(date);
        return classifyPoMapper.insertSelective(classifyPo);
    }

    @Override
    public Integer update(ClassifyPo classifyPo) {
        classifyPo.setClassifyCreate(null);
        classifyPo.setClassifyUpdate(DateUtil.date());
        return classifyPoMapper.updateByPrimaryKeySelective(classifyPo);
    }
}
